package fa7.socialcode.validator;

import javax.faces.*;
import javax.faces.validator.*;
import javax.faces.application.*;
import javax.faces.component.*;
import javax.faces.context.*;
import java.util.regex.*;

public class validation implements Validator{
public validation(){}

public void validate(FacesContext facesContext, UIComponent uIComponent, Object object) throws ValidatorException{
		String enteredEmail = (String)object;
		Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
		Matcher m = p.matcher(enteredEmail);
		boolean matchFound = m.matches();
		
		if (!matchFound) {
				FacesMessage message = new FacesMessage();
				message.setSummary("Email Invalido");
				throw new ValidatorException(message);
				}
		}
}